package com.wicket.okrcomponent.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.wicket.okrcomponent.biz.service.dto.req.*;
import com.wicket.okrcomponent.biz.service.dto.res.*;
import com.wicket.okrcomponent.common.exception.BizException;
import com.wicket.okrcomponent.common.util.CommonFunctionHelper;
import com.wicket.okrcomponent.common.util.RedisUtil;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.wicket.okrcomponent.base.service.MOmsMessageService;
import com.wicket.okrcomponent.dal.po.mbg.OmsMessage;
import com.wicket.okrcomponent.common.exception.Assert;
import com.wicket.okrcomponent.base.service.dto.req.QueryMessageDetailReq;
import com.wicket.okrcomponent.base.service.MOmsMessageMemberService;
import com.wicket.okrcomponent.dal.po.mbg.OmsMessageMember;
import com.wicket.okrcomponent.base.service.dto.req.QueryMemberMsgReceiveDetailReq;
import com.wicket.okrcomponent.base.service.MOmsMessageLocationRemindService;
import com.wicket.okrcomponent.dal.po.mbg.OmsMessageLocationRemind;
import com.wicket.okrcomponent.base.service.dto.req.QueryMessageNumDetailReq;
import com.wicket.okrcomponent.base.service.dto.req.QueryMemberMsgReceiveListReq;
import java.util.ArrayList;
import java.util.Collections;
import com.wicket.okrcomponent.biz.service.MessageService;
import com.wicket.okrcomponent.base.service.MOmsMessageChannelService;
import com.wicket.okrcomponent.dal.po.mbg.OmsMessageChannel;
import com.wicket.okrcomponent.base.service.dto.req.QueryChannelDetailReq;
import cn.hutool.core.collection.CollectionUtil;
import com.wicket.okrcomponent.biz.service.TemplateEngineService;
import com.wicket.okrcomponent.biz.service.nb.NbCommunication;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@Service
public class CommunicationServiceImpl
  implements com.wicket.okrcomponent.biz.service.CommunicationService {

  @Resource
  private RedisUtil redisUtil;
@Resource
  private MOmsMessageService mOmsMessageService;
@Resource
  private MOmsMessageMemberService mOmsMessageMemberService;
@Resource
  private MOmsMessageLocationRemindService mOmsMessageLocationRemindService;
//@Resource
 //private undefinedService undefinedService;
@Resource
  private MessageService messageService;
@Resource
  private MOmsMessageChannelService mOmsMessageChannelService;
@Resource
  private TemplateEngineService templateEngineService;
//@Resource
 //private MCustomFields4Service mCustomFields4Service;
@Resource
  private NbCommunication nbCommunication;
/**
   * D2修改变更消息内容(公共)[8355]
   * gen by moon at 1/25/2024, 9:46:50 PM
   */
  @Trace(operationName = "D2修改变更消息内容(公共)")
  @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Transactional(rollbackFor=Exception.class)
  @Override
  public UpdateChangeMessageContentComRespDto updateChangeMessageContentCom(UpdateChangeMessageContentComReqDto reqDto){
    
      
      //步骤0: 2-5-03修改消息 - updateMessage
     boolean bOOLEAN ;
    OmsMessage omsMessage=new OmsMessage();
  omsMessage.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME//sourceId:1507920_1
if(reqDto!=null){
      omsMessage.setMessageId(reqDto.getMessageId());//SimpleFieldAssign//sourceId:1507918_1
omsMessage.setMessageTitle(reqDto.getMessageTitle());//SimpleFieldAssign//sourceId:1507942_1
omsMessage.setMessageContent(reqDto.getMessageContent());//SimpleFieldAssign//sourceId:1507943_1
omsMessage.setReferenceMessageId(reqDto.getReferenceMessageId());//SimpleFieldAssign//sourceId:1507944_1
omsMessage.setReferenceMessageContent(reqDto.getReferenceMessageContent());//SimpleFieldAssign//sourceId:1507945_1
omsMessage.setIsBoutique(reqDto.getIsBoutique());//SimpleFieldAssign//sourceId:1507946_1
omsMessage.setThemeContentTypeCode(reqDto.getThemeContentTypeCode());//SimpleFieldAssign//sourceId:1507949_1
omsMessage.setThemeContentId(reqDto.getThemeContentId());//SimpleFieldAssign//sourceId:1507950_1
omsMessage.setCooperateContentTypeCode(reqDto.getCooperateContentTypeCode());//SimpleFieldAssign//sourceId:1507951_1
omsMessage.setCooperateContentId(reqDto.getCooperateContentId());//SimpleFieldAssign//sourceId:1507952_1
omsMessage.setSurfaceContName(reqDto.getSurfaceContName());//SimpleFieldAssign//sourceId:1507953_1
omsMessage.setMediaType(reqDto.getMediaType());//SimpleFieldAssign//sourceId:1507954_1
omsMessage.setMediaAddress(reqDto.getMediaAddress());//SimpleFieldAssign//sourceId:1507955_1
    }
  
    /*2-5-03修改消息[7522]   */
    Assert.isNull(omsMessage.getMessageId(),"D2修改变更消息内容(公共)-2-5-03修改消息-消息ID不能为空",false);
Assert.isNull(omsMessage.getOperateTime(),"D2修改变更消息内容(公共)-2-5-03修改消息-操作时间不能为空",false);
      bOOLEAN = mOmsMessageService.updateMessage(omsMessage)/*vcase invoke 本地 method 方法调用;*/;
      
      
      
    
UpdateChangeMessageContentComRespDto retData = new UpdateChangeMessageContentComRespDto();
  
  

  
  
return retData;
  }
/**
   * D2执行删除消息及相关(公共)[8351]
   * gen by moon at 1/27/2024, 5:52:18 PM
   */
  @Trace(operationName = "D2执行删除消息及相关(公共)")
  @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Transactional(rollbackFor=Exception.class)
  @Override
  public ImplementRemovalMessageCorrelationComRespDto implementRemovalMessageCorrelationCom(ImplementRemovalMessageCorrelationComReqDto reqDto){
    
      
      //virtualUsage 2-5-02查询当前消息是否已经精品  60228
      OmsMessage omsMessage = null;
    QueryMessageDetailReq queryMessageDetailReq=new QueryMessageDetailReq();
  if(reqDto!=null){
      queryMessageDetailReq.setMessageId(reqDto.getMessageId());//SimpleFieldAssign//sourceId:1507722_1_60228
queryMessageDetailReq.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:1507723_1_60228
    }
  
    /*2-5-02查询当前消息是否已经精品[7115]   */
    Assert.isNull(queryMessageDetailReq.getMessageId(),"D2执行删除消息及相关(公共)-2-5-02查询当前消息是否已经精品-消息ID不能为空",false);
Assert.isNull(queryMessageDetailReq.getSpaceId(),"D2执行删除消息及相关(公共)-2-5-02查询当前消息是否已经精品-创建于空间ID不能为空",false);
      omsMessage = mOmsMessageService.queryMessageDetail(queryMessageDetailReq)/*vcase invoke 本地 method 方法调用;*/;
      
      
      
if((reqDto!= null&& reqDto.getMemberMessageId() != null &&omsMessage!= null&&  omsMessage.getIsBoutique() !=null && omsMessage.getIsBoutique().equals("FALSE"))) {
        //if((D2执行删除消息及相关(公共).成员接收消息ID 值不等于空  and 2-5-02查询当前消息是否已经精品.是否精品 等于 否))  60215
        
OmsMessageMember omsMessageMember = null;
    QueryMemberMsgReceiveDetailReq queryMemberMsgReceiveDetailReq=new QueryMemberMsgReceiveDetailReq();
  queryMemberMsgReceiveDetailReq.setIsRead("FALSE");//sourceId:1507637_1_60219
if(reqDto!=null){
      queryMemberMsgReceiveDetailReq.setMemberMessageId(reqDto.getMemberMessageId());//SimpleFieldAssign//sourceId:1507636_1_60219
queryMemberMsgReceiveDetailReq.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:1507638_1_60219
    }
  
    /*2-5-03查询成员消息接收详情[7057]   */
    Assert.isNull(queryMemberMsgReceiveDetailReq.getMemberMessageId(),"D2执行删除消息及相关(公共)-2-5-03查询成员消息接收详情-成员接收消息ID不能为空",false);
Assert.isNull(queryMemberMsgReceiveDetailReq.getIsRead(),"D2执行删除消息及相关(公共)-2-5-03查询成员消息接收详情-是否已读不能为空",false);
Assert.isNull(queryMemberMsgReceiveDetailReq.getSpaceId(),"D2执行删除消息及相关(公共)-2-5-03查询成员消息接收详情-创建于空间ID不能为空",false);
      omsMessageMember = mOmsMessageMemberService.queryMemberMsgReceiveDetail(queryMemberMsgReceiveDetailReq)/*vcase invoke 本地 method 方法调用;*/;
      
      
      
if((omsMessageMember != null &&omsMessageMember!= null&& omsMessageMember.getMemberChannelRelationId() != null )) {
        //if((2-5-03查询成员消息接收详情.出参 值不等于空  and 2-5-03查询成员消息接收详情.成员通道关系ID 值不等于空 ))  60220
        
OmsMessageLocationRemind omsMessageLocationRemind = null;
    if(omsMessageMember !=null){
          QueryMessageNumDetailReq queryMessageNumDetailReq=new QueryMessageNumDetailReq();
  if(omsMessageMember!=null){
      queryMessageNumDetailReq.setEntityId(omsMessageMember.getMemberChannelRelationId());//SimpleFieldAssign//sourceId:1507665_1_60221
    }
if(reqDto!=null){
      queryMessageNumDetailReq.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:1507666_1_60221
    }
  
    /*2-5-04查通道成员关系关联的消息数量ID[3998]   */
    Assert.isNull(queryMessageNumDetailReq.getEntityId(),"D2执行删除消息及相关(公共)-2-5-04查通道成员关系关联的消息数量ID-归属内容ID不能为空",false);
Assert.isNull(queryMessageNumDetailReq.getSpaceId(),"D2执行删除消息及相关(公共)-2-5-04查通道成员关系关联的消息数量ID-创建于空间ID不能为空",false);
      omsMessageLocationRemind = mOmsMessageLocationRemindService.queryMessageNumDetail(queryMessageNumDetailReq)/*vcase invoke 本地 method 方法调用;*/;
      Assert.isTrue(omsMessageLocationRemind== null||  omsMessageLocationRemind.getMessageLocationRemindId() ==null,"找不到数据，系统异常",false);
      
      
           }
RefreshMessageIsReadMinusOneComRespDto refreshMessageIsReadMinusOneComRespDto = null;
    if(omsMessageMember !=null&&omsMessageLocationRemind !=null){
          RefreshMessageIsReadMinusOneComReqDto refreshMessageIsReadMinusOneComReqDto=new RefreshMessageIsReadMinusOneComReqDto();
  if(reqDto!=null){
      refreshMessageIsReadMinusOneComReqDto.setMessageLocationTypeCode(reqDto.getMessageLocationTypeCode());//SimpleFieldAssign//sourceId:1506848_1_60222
refreshMessageIsReadMinusOneComReqDto.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:1506853_1_60222
    }
if(omsMessageMember!=null){
      refreshMessageIsReadMinusOneComReqDto.setMemberMessageId(omsMessageMember.getMemberMessageId());//SimpleFieldAssign//sourceId:1506849_1_60222
refreshMessageIsReadMinusOneComReqDto.setOriginalRoleMemberId(omsMessageMember.getOriginalRoleMemberId());//SimpleFieldAssign//sourceId:1506851_1_60222
refreshMessageIsReadMinusOneComReqDto.setUserId(omsMessageMember.getUserId());//SimpleFieldAssign//sourceId:1506852_1_60222
    }
if(omsMessageLocationRemind!=null){
      refreshMessageIsReadMinusOneComReqDto.setMessageLocationRemindId(omsMessageLocationRemind.getMessageLocationRemindId());//SimpleFieldAssign//sourceId:1506850_1_60222
    }
  
    /*D2更新消息已读数量减一(公共)[6926]   */
    Assert.isNull(refreshMessageIsReadMinusOneComReqDto.getMessageLocationTypeCode(),"D2执行删除消息及相关(公共)-D2更新消息已读数量减一(公共)-消息位置标识不能为空",false);
Assert.isNull(refreshMessageIsReadMinusOneComReqDto.getMemberMessageId(),"D2执行删除消息及相关(公共)-D2更新消息已读数量减一(公共)-成员接收消息ID不能为空",false);
Assert.isNull(refreshMessageIsReadMinusOneComReqDto.getMessageLocationRemindId(),"D2执行删除消息及相关(公共)-D2更新消息已读数量减一(公共)-消息数量ID不能为空",false);
Assert.isNull(refreshMessageIsReadMinusOneComReqDto.getOriginalRoleMemberId(),"D2执行删除消息及相关(公共)-D2更新消息已读数量减一(公共)-归属身份人员ID不能为空",false);
Assert.isNull(refreshMessageIsReadMinusOneComReqDto.getUserId(),"D2执行删除消息及相关(公共)-D2更新消息已读数量减一(公共)-归属个人账号ID不能为空",false);
Assert.isNull(refreshMessageIsReadMinusOneComReqDto.getSpaceId(),"D2执行删除消息及相关(公共)-D2更新消息已读数量减一(公共)-创建于空间ID不能为空",false);
      refreshMessageIsReadMinusOneComRespDto = messageService.refreshMessageIsReadMinusOneCom(refreshMessageIsReadMinusOneComReqDto)/*vcase invoke isSameApp*/;
      
      
      
           }
List<OmsMessageMember> listOmsMessageMember =new ArrayList<>();
    if(omsMessageMember !=null){
    QueryMemberMsgReceiveListReq queryMemberMsgReceiveListReq=new QueryMemberMsgReceiveListReq();
if(reqDto!=null){
      queryMemberMsgReceiveListReq.setMessageId(reqDto.getMessageId());//SimpleFieldAssign//sourceId:1510275_1_60316
queryMemberMsgReceiveListReq.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:1510269_1_60316
    }
if(omsMessageMember!=null){
      queryMemberMsgReceiveListReq.setMessageChannelId(omsMessageMember.getMessageChannelId());//SimpleFieldAssign//sourceId:1510268_1_60316
    }
  
    /*2-5-03查询成员消息接收列表[4029]   */
    Assert.isNull(queryMemberMsgReceiveListReq.getMessageId(),"D2执行删除消息及相关(公共)-2-5-03查询成员消息接收列表-接收的消息ID不能为空",false);
Assert.isNull(queryMemberMsgReceiveListReq.getSpaceId(),"D2执行删除消息及相关(公共)-2-5-03查询成员消息接收列表-创建于空间ID不能为空",false);
      listOmsMessageMember = mOmsMessageMemberService.queryMemberMsgReceiveList(queryMemberMsgReceiveListReq)/*vcase invoke 本地 method 方法调用;*/;
      
      
      
           }
boolean bOOLEAN ;
    if(listOmsMessageMember !=null&& !CollectionUtil.isEmpty(listOmsMessageMember)&& listOmsMessageMember.size()>0 ){
          List<String> listString=new ArrayList<>();
  if(listOmsMessageMember!= null&& !CollectionUtil.isEmpty(listOmsMessageMember)&&  listOmsMessageMember !=null&& !CollectionUtil.isEmpty(listOmsMessageMember)){
      listString = listOmsMessageMember.stream().map(item->item.getMemberMessageId())
        .collect(Collectors.toList());/*list-to-strings*///sourceId:1510281_1_60317
    }

    /*2-5-03批量删成员消息接收[7606]   */

      bOOLEAN = mOmsMessageMemberService.batchDeleteMemberMsgReceive(listString)/*vcase invoke 本地 method 方法调用;*/;



           }
      }
      }
else if((reqDto!= null&& reqDto.getMemberMessageId() == null &&omsMessage!= null&&  omsMessage.getIsBoutique() !=null && omsMessage.getIsBoutique().equals("FALSE"))){
       //elseif((D2执行删除消息及相关(公共).成员接收消息ID 值等于空  and 2-5-02查询当前消息是否已经精品.是否精品 等于 否))  60216

List<OmsMessageMember> listOmsMessageMember_2 =new ArrayList<>();
    QueryMemberMsgReceiveListReq queryMemberMsgReceiveListReq_1=new QueryMemberMsgReceiveListReq();
  queryMemberMsgReceiveListReq_1.setIsRead("FALSE");//sourceId:1507639_1_60223
if(reqDto!=null){
      queryMemberMsgReceiveListReq_1.setMessageId(reqDto.getMessageId());//SimpleFieldAssign//sourceId:1507609_1_60223
queryMemberMsgReceiveListReq_1.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:1507610_1_60223
    }

    /*2-5-03查询成员消息接收列表[4029]   */
    Assert.isNull(queryMemberMsgReceiveListReq_1.getMessageId(),"D2执行删除消息及相关(公共)-2-5-03查询成员消息接收列表-接收的消息ID不能为空",false);
Assert.isNull(queryMemberMsgReceiveListReq_1.getIsRead(),"D2执行删除消息及相关(公共)-2-5-03查询成员消息接收列表-是否已读不能为空",false);
Assert.isNull(queryMemberMsgReceiveListReq_1.getSpaceId(),"D2执行删除消息及相关(公共)-2-5-03查询成员消息接收列表-创建于空间ID不能为空",false);
      listOmsMessageMember_2 = mOmsMessageMemberService.queryMemberMsgReceiveList(queryMemberMsgReceiveListReq_1)/*vcase invoke 本地 method 方法调用;*/;



//ModelCode: circulationCollections
        for (OmsMessageMember circulationCollectionsRes: listOmsMessageMember_2){
      
OmsMessageLocationRemind omsMessageLocationRemind_2 = null;
    QueryMessageNumDetailReq queryMessageNumDetailReq_1=new QueryMessageNumDetailReq();
  if(circulationCollectionsRes!=null){
      queryMessageNumDetailReq_1.setEntityId(circulationCollectionsRes.getMemberChannelRelationId());//SimpleFieldAssign//sourceId:1507665_1_60226
    }
if(reqDto!=null){
      queryMessageNumDetailReq_1.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:1507666_1_60226
    }
  
    /*2-5-04查通道成员关系关联的消息数量ID[3998]   */
    Assert.isNull(queryMessageNumDetailReq_1.getEntityId(),"D2执行删除消息及相关(公共)-2-5-04查通道成员关系关联的消息数量ID-归属内容ID不能为空",false);
Assert.isNull(queryMessageNumDetailReq_1.getSpaceId(),"D2执行删除消息及相关(公共)-2-5-04查通道成员关系关联的消息数量ID-创建于空间ID不能为空",false);
      omsMessageLocationRemind_2 = mOmsMessageLocationRemindService.queryMessageNumDetail(queryMessageNumDetailReq_1)/*vcase invoke 本地 method 方法调用;*/;
      Assert.isTrue(omsMessageLocationRemind_2== null||  omsMessageLocationRemind_2.getMessageLocationRemindId() ==null,"找不到数据，系统异常",false);
      
      
RefreshMessageIsReadMinusOneComRespDto refreshMessageIsReadMinusOneComRespDto_1 = null;
    if(omsMessageLocationRemind_2 !=null){
          RefreshMessageIsReadMinusOneComReqDto refreshMessageIsReadMinusOneComReqDto_1=new RefreshMessageIsReadMinusOneComReqDto();
  if(reqDto!=null){
      refreshMessageIsReadMinusOneComReqDto_1.setMessageLocationTypeCode(reqDto.getMessageLocationTypeCode());//SimpleFieldAssign//sourceId:1506848_1_60227
refreshMessageIsReadMinusOneComReqDto_1.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:1506853_1_60227
    }
if(circulationCollectionsRes!=null){
      refreshMessageIsReadMinusOneComReqDto_1.setMemberMessageId(circulationCollectionsRes.getMemberMessageId());//SimpleFieldAssign//sourceId:1506849_1_60227
refreshMessageIsReadMinusOneComReqDto_1.setOriginalRoleMemberId(circulationCollectionsRes.getOriginalRoleMemberId());//SimpleFieldAssign//sourceId:1506851_1_60227
refreshMessageIsReadMinusOneComReqDto_1.setUserId(circulationCollectionsRes.getUserId());//SimpleFieldAssign//sourceId:1506852_1_60227
    }
if(omsMessageLocationRemind_2!=null){
      refreshMessageIsReadMinusOneComReqDto_1.setMessageLocationRemindId(omsMessageLocationRemind_2.getMessageLocationRemindId());//SimpleFieldAssign//sourceId:1506850_1_60227
    }
  
    /*D2更新消息已读数量减一(公共)[6926]   */
    Assert.isNull(refreshMessageIsReadMinusOneComReqDto_1.getMessageLocationTypeCode(),"D2执行删除消息及相关(公共)-D2更新消息已读数量减一(公共)-消息位置标识不能为空",false);
Assert.isNull(refreshMessageIsReadMinusOneComReqDto_1.getMemberMessageId(),"D2执行删除消息及相关(公共)-D2更新消息已读数量减一(公共)-成员接收消息ID不能为空",false);
Assert.isNull(refreshMessageIsReadMinusOneComReqDto_1.getMessageLocationRemindId(),"D2执行删除消息及相关(公共)-D2更新消息已读数量减一(公共)-消息数量ID不能为空",false);
Assert.isNull(refreshMessageIsReadMinusOneComReqDto_1.getOriginalRoleMemberId(),"D2执行删除消息及相关(公共)-D2更新消息已读数量减一(公共)-归属身份人员ID不能为空",false);
Assert.isNull(refreshMessageIsReadMinusOneComReqDto_1.getUserId(),"D2执行删除消息及相关(公共)-D2更新消息已读数量减一(公共)-归属个人账号ID不能为空",false);
Assert.isNull(refreshMessageIsReadMinusOneComReqDto_1.getSpaceId(),"D2执行删除消息及相关(公共)-D2更新消息已读数量减一(公共)-创建于空间ID不能为空",false);
      refreshMessageIsReadMinusOneComRespDto_1 = messageService.refreshMessageIsReadMinusOneCom(refreshMessageIsReadMinusOneComReqDto_1)/*vcase invoke isSameApp*/;
      
      
      
           }
//ModelCode: circulationEnd
        }
      
List<OmsMessageMember> listOmsMessageMember_4 =new ArrayList<>();
    QueryMemberMsgReceiveListReq queryMemberMsgReceiveListReq_2=new QueryMemberMsgReceiveListReq();
  if(reqDto!=null){
      queryMemberMsgReceiveListReq_2.setMessageId(reqDto.getMessageId());//SimpleFieldAssign//sourceId:1510275_1_60319
queryMemberMsgReceiveListReq_2.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:1510269_1_60319
    }

    /*2-5-03查询成员消息接收列表[4029]   */
    Assert.isNull(queryMemberMsgReceiveListReq_2.getMessageId(),"D2执行删除消息及相关(公共)-2-5-03查询成员消息接收列表-接收的消息ID不能为空",false);
Assert.isNull(queryMemberMsgReceiveListReq_2.getSpaceId(),"D2执行删除消息及相关(公共)-2-5-03查询成员消息接收列表-创建于空间ID不能为空",false);
      listOmsMessageMember_4 = mOmsMessageMemberService.queryMemberMsgReceiveList(queryMemberMsgReceiveListReq_2)/*vcase invoke 本地 method 方法调用;*/;



boolean bOOLEAN_1 ;
    if(listOmsMessageMember_4 !=null&& !CollectionUtil.isEmpty(listOmsMessageMember_4)&& listOmsMessageMember_4.size()>0 ){
          List<String> listString_1=new ArrayList<>();
  if(listOmsMessageMember_4!= null&& !CollectionUtil.isEmpty(listOmsMessageMember_4)&&  listOmsMessageMember_4 !=null&& !CollectionUtil.isEmpty(listOmsMessageMember_4)){
      listString_1 = listOmsMessageMember_4.stream().map(item->item.getMemberMessageId())
        .collect(Collectors.toList());/*list-to-strings*///sourceId:1510281_1_60320
    }

    /*2-5-03批量删成员消息接收[7606]   */

      bOOLEAN_1 = mOmsMessageMemberService.batchDeleteMemberMsgReceive(listString_1)/*vcase invoke 本地 method 方法调用;*/;



           }
    }
else{
       //else  60217
      
//异常结束 60218
      throw new BizException("500","系统异常，请联系管理员！",false);
    }
//virtualUsage 2-5-02删除消息  60318
      boolean bOOLEAN_2 ;
    String string=new String();
  if(reqDto!=null){
      string=reqDto.getMessageId();;//SimpleFieldAssign//sourceId:1510282_1_60318
    }

    /*2-5-02删除消息[3984]   */
    Assert.isNull(string,"D2执行删除消息及相关(公共)-2-5-02删除消息-消息ID不能为空",false);
      bOOLEAN_2 = mOmsMessageService.deleteMessage(string)/*vcase invoke 本地 method 方法调用;*/;



ImplementRemovalMessageCorrelationComRespDto retData = new ImplementRemovalMessageCorrelationComRespDto();
  
  

  
  
return retData;
  }

/**
   * D2执行分享想法后回删(公共)[8360]
   * gen by moon at 1/27/2024, 7:50:02 PM
   */
  @Trace(operationName = "D2执行分享想法后回删(公共)")
  @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Transactional(rollbackFor=Exception.class)
  @Override
  public ImplementShareIdeasDeleteBackComRespDto implementShareIdeasDeleteBackCom(ImplementShareIdeasDeleteBackComReqDto reqDto){


      //步骤0: M2执行智能沟通接收入参 - implementSmartSessionReceiveFieldInput
     //ModelCode: receptionService
        ImplementSmartSessionReceiveFieldInputRespDto receptionServiceRes = null;
    ImplementSmartSessionReceiveFieldInputReqDto receptionServiceReq=new ImplementSmartSessionReceiveFieldInputReqDto();
  if(reqDto!=null){
      receptionServiceReq.setMessageId(reqDto.getMessageId());//SimpleFieldAssign//sourceId:1508948_1
receptionServiceReq.setMessageId(reqDto.getReceiveMessageId());//SimpleFieldAssign//sourceId:1508950_1
receptionServiceReq.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:1508951_1
    }

    /*M2执行智能沟通接收入参[8109]  用于特殊方法接收上游入参。 */
    Assert.isNull(receptionServiceReq.getMessageId(),"D2执行分享想法后回删(公共)-M2执行智能沟通接收入参-消息ID不能为空",false);
Assert.isNull(receptionServiceReq.getMessageId(),"D2执行分享想法后回删(公共)-M2执行智能沟通接收入参-接收的消息ID不能为空",false);
Assert.isNull(receptionServiceReq.getSpaceId(),"D2执行分享想法后回删(公共)-M2执行智能沟通接收入参-创建于空间ID不能为空",false);
      receptionServiceRes = nbCommunication.implementSmartSessionReceiveFieldInput(receptionServiceReq);




//步骤1: 2-5-02删除消息 - deleteMessage
     boolean bOOLEAN ;
    String string=new String();
  if(reqDto!=null){
      string=reqDto.getMessageId();;//SimpleFieldAssign//sourceId:1508668_1
    }

    /*2-5-02删除消息[3984]   */
    Assert.isNull(string,"D2执行分享想法后回删(公共)-2-5-02删除消息-消息ID不能为空",false);
      bOOLEAN = mOmsMessageService.deleteMessage(string)/*vcase invoke 本地 method 方法调用;*/;




//步骤2: 2-5-03查询成员消息接收列表 - queryMemberMsgReceiveList
     List<OmsMessageMember> listOmsMessageMember =new ArrayList<>();
    QueryMemberMsgReceiveListReq queryMemberMsgReceiveListReq=new QueryMemberMsgReceiveListReq();
  if(reqDto!=null){
      queryMemberMsgReceiveListReq.setMessageId(reqDto.getMessageId());//SimpleFieldAssign//sourceId:1508682_1
queryMemberMsgReceiveListReq.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:1508683_1
    }

    /*2-5-03查询成员消息接收列表[4029]   */
    Assert.isNull(queryMemberMsgReceiveListReq.getMessageId(),"D2执行分享想法后回删(公共)-2-5-03查询成员消息接收列表-接收的消息ID不能为空",false);
Assert.isNull(queryMemberMsgReceiveListReq.getSpaceId(),"D2执行分享想法后回删(公共)-2-5-03查询成员消息接收列表-创建于空间ID不能为空",false);
      listOmsMessageMember = mOmsMessageMemberService.queryMemberMsgReceiveList(queryMemberMsgReceiveListReq)/*vcase invoke 本地 method 方法调用;*/;




//步骤3: 2-5-03批量改成员消息接收 - batchUpdateMemberMsgReceive
     boolean bOOLEAN_1 ;
    if(listOmsMessageMember !=null&& !CollectionUtil.isEmpty(listOmsMessageMember)&& listOmsMessageMember.size()>0 ){
          List<OmsMessageMember> listOmsMessageMember_2=new ArrayList<>();
  if(listOmsMessageMember!= null&& !CollectionUtil.isEmpty(listOmsMessageMember)&&  listOmsMessageMember !=null&& !CollectionUtil.isEmpty(listOmsMessageMember)){
      listOmsMessageMember_2 = //objList-to-objLists
        listOmsMessageMember.stream().map(item -> {
      OmsMessageMember elm = new OmsMessageMember();
      elm.setMemberMessageId(item.getMemberMessageId());//SimpleFieldAssign//sourceId:296565_2
if(reqDto!=null){
      elm.setMessageId(reqDto.getReceiveMessageId());//两个数组关联数量不一致; 导致逐个赋值; 有概率付错值; //SimpleFieldAssign//sourceId:296571_2
    }
        return elm;
      }).collect(Collectors.toList());//objList-to-objLists//sourceId:1508685_1
    }

    /*2-5-03批量改成员消息接收[7362]   */

      bOOLEAN_1 = mOmsMessageMemberService.batchUpdateMemberMsgReceive(listOmsMessageMember_2)/*vcase invoke 本地 method 方法调用;*/;



           }

//步骤4: 2-5-03修改消息 - updateMessage
     boolean bOOLEAN_2 ;
    OmsMessage omsMessage=new OmsMessage();
  omsMessage.setIsHandle("TRUE");//sourceId:1510299_1
omsMessage.setHandleType("NEED_HANDLING");//sourceId:1510313_1
omsMessage.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME//sourceId:1510300_1
if(reqDto!=null){
      omsMessage.setMessageId(reqDto.getReceiveMessageId());//SimpleFieldAssign//sourceId:1510298_1
    }

    /*2-5-03修改消息[7522]   */
    Assert.isNull(omsMessage.getMessageId(),"D2执行分享想法后回删(公共)-2-5-03修改消息-消息ID不能为空",false);
Assert.isNull(omsMessage.getIsHandle(),"D2执行分享想法后回删(公共)-2-5-03修改消息-是否已处理不能为空",false);
Assert.isNull(omsMessage.getHandleType(),"D2执行分享想法后回删(公共)-2-5-03修改消息-处理类型不能为空",false);
Assert.isNull(omsMessage.getOperateTime(),"D2执行分享想法后回删(公共)-2-5-03修改消息-操作时间不能为空",false);
      bOOLEAN_2 = mOmsMessageService.updateMessage(omsMessage)/*vcase invoke 本地 method 方法调用;*/;




ImplementShareIdeasDeleteBackComRespDto retData = new ImplementShareIdeasDeleteBackComRespDto();





return retData;
  }
  //
}
